package test;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
//import de.innosystec.unrar.Archive;  

public class UnZip {
	static final int BUFFER = 2048;

	public static void main(String argv[]) {
		try {
		 

			String path = "E:/index_loan.zip";
			BufferedOutputStream dest = null;
			FileInputStream fis = new FileInputStream(path);
			ZipInputStream zis = new ZipInputStream(
					new BufferedInputStream(fis));
			ZipEntry entry;
			while ((entry = zis.getNextEntry()) != null) {
				System.out.println("Extracting: " + entry);
				int count;
				byte data[] = new byte[BUFFER];
				// write the files to the disk
				FileOutputStream fos = new FileOutputStream("E:/"+entry.getName());
				dest = new BufferedOutputStream(fos, BUFFER);
				while ((count = zis.read(data, 0, BUFFER)) != -1) {
					dest.write(data, 0, count);
				}
				dest.flush();
				dest.close();
			}
			System.out.println("success");
			zis.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
//	 public synchronized void unrar(String rarFileName, String extPlace) throws Exception{   
//	        try {   
//	            (new File(extPlace)).mkdirs();   
//	            // 构建测解压缩类   
//	            Archive archive = new Archive();   
////	            archive.setEnabledLog(false); //不输出日志   
//	            // 设置rar文件   
//	            archive.setFile(rarFileName);   
//	            archive.setExtractPath(extPlace);   
//	            archive.extractAllFile();   
//	        } catch (Exception e) {   
//	            // TODO: handle exception   
//	        }   
//	    }

}
